package org.come.Jpanel;

import com.tool.btn.FormsOnOffBtn;
import com.tool.btn.LiangHaoBtn;
import com.tool.btn.LiangHaoItemBtn;
import com.tool.btn.LiangHaoPaiBtn;
import com.tool.role.RoleData;
import com.tool.tcpimg.UIUtils;
import com.updateNew.MyIsif;
import org.apache.commons.lang.StringUtils;
import org.come.bean.LoginResult;
import org.come.until.CutButtonImage;

import javax.swing.*;
import java.awt.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.Calendar;
import java.util.Date;

@SuppressWarnings("serial")
public class ContinueLiangHaoJpanel extends JPanel {


    private LiangHaoItemBtn sureBtn, cancelBtn;
    private JLabel lab1, lab2, lab3, lab4, lab5, lab6;


    public ContinueLiangHaoJpanel() {
        String style = MyIsif.getStyle();
        if ("水墨UI".equals(style)) {
            this.setPreferredSize(new Dimension(342, 323));
            this.setLayout(null);
            this.setBackground(UIUtils.Color_BACK);
            FormsOnOffBtn offBtn = new FormsOnOffBtn("inkImg/button/1.png", 1, 706);
            offBtn.setBounds(342 - 35, 10, 25, 25);
            this.add(offBtn);

            sureBtn = new LiangHaoItemBtn("inkImg/newbutton/B20.png", 1, this, 70, "确定");
            this.sureBtn.setBounds(80, 275, 60, 25);
            this.sureBtn.setFont(UIUtils.TEXT_HY16);
            this.sureBtn.setVerticalTextPosition(SwingConstants.CENTER);
            this.sureBtn.setHorizontalTextPosition(SwingConstants.CENTER);
            this.add(this.sureBtn);

            cancelBtn = new LiangHaoItemBtn("inkImg/newbutton/B20.png", 1, this, 71, "取消");
            this.cancelBtn.setBounds(200, 275, 60, 25);
            this.cancelBtn.setFont(UIUtils.TEXT_HY16);
            this.cancelBtn.setVerticalTextPosition(SwingConstants.CENTER);
            this.cancelBtn.setHorizontalTextPosition(SwingConstants.CENTER);
            this.add(this.cancelBtn);

            Font font = new Font("宋体", 0, 14);
            lab1 = new JLabel();
            lab1.setBounds(140, 249, 120, 15);
            lab1.setFont(font);
            lab1.setForeground(Color.WHITE);
            this.add(lab1);

            lab2 = new JLabel();
            lab2.setBounds(140, 221, 120, 15);
            lab2.setFont(font);
            lab2.setForeground(Color.WHITE);
            this.add(lab2);

            lab3 = new JLabel();
            lab3.setBounds(140, 193, 120, 15);
            lab3.setFont(font);
            lab3.setForeground(Color.WHITE);
            this.add(lab3);

            lab4 = new JLabel();
            lab4.setBounds(140, 164, 120, 15);
            lab4.setFont(font);
            lab4.setForeground(Color.WHITE);
            this.add(lab4);

            lab5 = new JLabel();
            lab5.setBounds(120, 130, 120, 15);
            lab5.setForeground(Color.WHITE);
            lab5.setFont(font);
            this.add(lab5);

            lab6 = new JLabel();
            lab6.setBounds(190, 130, 120, 15);
            lab6.setForeground(Color.RED);
            lab6.setFont(font);
            this.add(lab6);
        } else {
            this.setPreferredSize(new Dimension(342, 323));
            this.setLayout(null);
            this.setBackground(UIUtils.Color_BACK);
            FormsOnOffBtn offBtn = new FormsOnOffBtn("inkImg/hongmu/gift-close-btn1.png", 1, 706);
            offBtn.setBounds(342 - 35, 10, 25, 25);
            this.add(offBtn);

            sureBtn = new LiangHaoItemBtn("inkImg/hongmu/60_26.png", 1, this, 70, "确定");
            this.sureBtn.setBounds(80, 275, 60, 25);
            this.sureBtn.setFont(UIUtils.TEXT_HY16);
            this.sureBtn.setVerticalTextPosition(SwingConstants.CENTER);
            this.sureBtn.setHorizontalTextPosition(SwingConstants.CENTER);
            this.sureBtn.setForeground(Color.YELLOW); // 设置字体颜色为黄色
            this.add(this.sureBtn);

            cancelBtn = new LiangHaoItemBtn("inkImg/hongmu/60_26.png", 1, this, 71, "取消");
            this.cancelBtn.setBounds(200, 275, 60, 25);
            this.cancelBtn.setFont(UIUtils.TEXT_HY16);
            this.cancelBtn.setVerticalTextPosition(SwingConstants.CENTER);
            this.cancelBtn.setHorizontalTextPosition(SwingConstants.CENTER);
            this.cancelBtn.setForeground(Color.YELLOW); // 设置字体颜色为黄色
            this.add(this.cancelBtn);

            Font font = new Font("宋体", 0, 14);
            lab1 = new JLabel();
            lab1.setBounds(140, 249, 120, 15);
            lab1.setFont(font);
            lab1.setForeground(Color.WHITE);
            this.add(lab1);

            lab2 = new JLabel();
            lab2.setBounds(140, 221, 120, 15);
            lab2.setFont(font);
            lab2.setForeground(Color.WHITE);
            this.add(lab2);

            lab3 = new JLabel();
            lab3.setBounds(140, 193, 120, 15);
            lab3.setFont(font);
            lab3.setForeground(Color.WHITE);
            this.add(lab3);

            lab4 = new JLabel();
            lab4.setBounds(140, 164, 120, 15);
            lab4.setFont(font);
            lab4.setForeground(Color.WHITE);
            this.add(lab4);

            lab5 = new JLabel();
            lab5.setBounds(120, 130, 120, 15);
            lab5.setForeground(Color.WHITE);
            lab5.setFont(font);
            this.add(lab5);

            lab6 = new JLabel();
            lab6.setBounds(190, 130, 120, 15);
            lab6.setForeground(Color.YELLOW);
            lab6.setFont(font);
            this.add(lab6);
        }
    }

    private ImageIcon iconBack;

    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        String style = MyIsif.getStyle();
        if ("水墨UI".equals(style)) {
            if (iconBack == null) {
                iconBack = new ImageIcon("inkImg/newbackground/addtime.png");
            }
            g.drawImage(iconBack.getImage(), 0, 0, 342, 323, this);
            lab1.setText(String.valueOf(RoleData.getRoleData().getLoginResult().getCodecard()));
            final LoginResult login = RoleData.getRoleData().getLoginResult();
            long Money = 200000;
            lab2.setText(String.valueOf(Money));
            lab3.setText(String.valueOf(Money));
            lab4.setText("30天");
            lab5.setText("剩余时间：");
            if (login.getLianghaoexpire() != null) {
                LocalDate expDate = LocalDate.parse(login.getLianghaoexpire());
                LocalDate nowDate = LocalDate.now();
                long daysBetween = ChronoUnit.DAYS.between(nowDate, expDate);
                lab6.setText(daysBetween + "天");
            }

            String num = login.getLiangHao();
            Integer type = login.getLianghaotype() == null ? 0 : login.getLianghaotype();
            if (StringUtils.isNotEmpty(num)) {
                String[] nums = num.split("");
                for (int j = 0; j < nums.length; j++) {
                    int xnum = 140 + (11 * j);
                    int ynum = 78;
                    g.drawImage(CutButtonImage.getImage("inkImg/number/" + String.valueOf(type) + nums[j] + ".png", 11, 15).getImage(), xnum, ynum, 11, 15, this);
                }
            }
        } else {
            if (iconBack == null) {
                iconBack = new ImageIcon("inkImg/hongmu/xufeihongmu.png");
            }
            g.drawImage(iconBack.getImage(), 0, 0, 342, 323, this);
            lab1.setText(String.valueOf(RoleData.getRoleData().getLoginResult().getCodecard()));
            final LoginResult login = RoleData.getRoleData().getLoginResult();
            long Money = 200000;
            lab2.setText(String.valueOf(Money));
            lab3.setText(String.valueOf(Money));
            lab4.setText("30天");
            lab5.setText("剩余时间：");
            if (login.getLianghaoexpire() != null) {
                LocalDate expDate = LocalDate.parse(login.getLianghaoexpire());
                LocalDate nowDate = LocalDate.now();
                long daysBetween = ChronoUnit.DAYS.between(nowDate, expDate);
                lab6.setText(daysBetween + "天");
            }

            String num = login.getLiangHao();
            Integer type = login.getLianghaotype() == null ? 0 : login.getLianghaotype();
            if (StringUtils.isNotEmpty(num)) {
                String[] nums = num.split("");
                for (int j = 0; j < nums.length; j++) {
                    int xnum = 140 + (11 * j);
                    int ynum = 78;
                    g.drawImage(CutButtonImage.getImage("inkImg/number/" + String.valueOf(type) + nums[j] + ".png", 11, 15).getImage(), xnum, ynum, 11, 15, this);
                }
            }
        }
    }

    public ImageIcon getIconBack() {
        return iconBack;
    }

    public void setIconBack(ImageIcon iconBack) {
        this.iconBack = iconBack;
    }

    public LiangHaoItemBtn getSureBtn() {
        return sureBtn;
    }

    public void setSureBtn(LiangHaoItemBtn sureBtn) {
        this.sureBtn = sureBtn;
    }

    public LiangHaoItemBtn getCancelBtn() {
        return cancelBtn;
    }

    public void setCancelBtn(LiangHaoItemBtn cancelBtn) {
        this.cancelBtn = cancelBtn;
    }

    public JLabel getLab1() {
        return lab1;
    }

    public void setLab1(JLabel lab1) {
        this.lab1 = lab1;
    }

    public JLabel getLab2() {
        return lab2;
    }

    public void setLab2(JLabel lab2) {
        this.lab2 = lab2;
    }

    public JLabel getLab3() {
        return lab3;
    }

    public void setLab3(JLabel lab3) {
        this.lab3 = lab3;
    }

    public JLabel getLab4() {
        return lab4;
    }

    public void setLab4(JLabel lab4) {
        this.lab4 = lab4;
    }

    public JLabel getLab5() {
        return lab5;
    }

    public void setLab5(JLabel lab5) {
        this.lab5 = lab5;
    }

    public JLabel getLab6() {
        return lab6;
    }

    public void setLab6(JLabel lab6) {
        this.lab6 = lab6;
    }
}
